package GuessMachine;

import java.util.Random;
import java.util.Scanner;

/**
 * @Author MDD
 * @Description
 * @Version
 * @Date
 **/
public class GuessMachine {
    double price;
    public String initial(){
        int random = (int)(Math.random()*3+1);

        for(int i=0;i<1;i++){
            if (random==1){
                this.price = 3399;
                return "小米电视";
            }
            else if (random==2){
                this.price = 5599;
                return "LG 电视";
            }else if (random==3){
                this.price = 12999;
                return "海尔电视";
            }
          }
        return "*******************";
    }



    public void guess(){
        GuessMachine guess = new GuessMachine();
        for (int i = 3; i >=1; i--) {
            System.out.print("请输入你猜的价格：");
            Scanner sc = new Scanner(System.in);
            double money = sc.nextDouble();
            if (money>price){
                System.out.println("再小一点");
            }
            else if (money<price){
                System.out.println("再大一点");
            }
            else if (money==price){
                System.out.println("恭喜您，猜对了");
                break;
            }
            if (i==1){
                System.out.println("竞猜次数仅限三次机会,下次继续努力！");
                break;
            }
        }
    }

    public static void main(String[] args) {
        GuessMachine cai = new GuessMachine();
        System.out.println(cai.initial());
        cai.guess();
    }
}
